<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
	<meta charset="utf-8" />
	<meta name="keywords" content="pinpin社保" />
	<meta name="description" content="pinpin社保" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="renderer" content="webkit" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>社保运营后台-用户管理</title>
	<%@ include file="/WEB-INF/jsp/common/common.jsp" %>
</head>
<body>
	<div id="wrapper">
		<%@ include file="/WEB-INF/jsp/common/menu.jsp" %>
        <div id="page-wrapper">
        	<div class="row">
                <div class="col-lg-12">
                    <!-- 路径导航 -->
                    <ol class="breadcrumb">
				      <li>社保后台</li>
				      <li class="active">参保人</li>
				    </ol>
                </div>
            </div>
            <div class="row">
            	<div class="col-lg-12">
            		<div class="panel panel-default">
            			<div class="panel-body">
            				<ul class="nav nav-tabs">
                                <li class="${shebao_user ? 'active' : '' }">
                                	<a href="#shebao_user" data-toggle="tab" onclick="javascript:tabSwitch(0)">参保人查询</a>
                                </li>
                                <li class="${shebao_user_buyed ? 'active' : '' }">
                                	<a href="#shebao_user_buyed" data-toggle="tab" onclick="javascript:tabSwitch(1)">参保人绑定</a>
                                </li>
                                <li class="${black_user ? 'active' : '' }">
                                	<a href="#black_user" data-toggle="tab" onclick="javascript:tabSwitch(2)">参保人黑名单</a>
                                </li>
                            </ul>
                            <div class="tab-content">
                            	<c:if test="${shebao_user}">
                                <div class="tab-pane fade in active" id="shebao_user">
		        			    	<div class="form-inline dt-bootstrap no-footer">
		        			    		<!-- 表单查询 -->
		        			    		<form action="${user_shebao_manage_uri }" method="post" id="queryForm" name="queryForm">
		        			    		<div class="row">
		        			    			<div class="col-lg-12">
		                                        <div class="col-lg-10">
		                                        	<textarea name="phones" cols="110" class="form-control" placeholder="多个用户手机以逗号间隔,可采用CSV格式文件辅助">${phones }</textarea>
				                                </div>
				                                <div class="col-lg-1">
			        			    			    <input type="submit" class="btn btn-primary" id="queryBtn" value="查 询" />
			        			    			</div>
				                                <div class="col-lg-1">
			        			    			    <input type="reset" class="btn btn-primary" id="resetBtn" value="重置" />
			        			    			</div>
		        			    			</div>
		        			    			<div class="col-lg-12" style="margin-top:10px">
		                                        <div class="col-lg-10">
		                                        	<textarea name="id_cards" cols="110" class="form-control" placeholder="多个身份证以逗号间隔,可采用CSV格式文件辅助">${id_cards }</textarea>
				                                </div>
				                                <div class="col-lg-2"><input type="button" class="btn btn-primary" value="导出为EXCEL" onclick="javascript:exportExcel();"/></div>
		        			    			</div>
		        			    		</div>
		        			    		</form>
		        			    		<hr />
		        			    		<!-- 表格列表 -->
		        			    		<div class="row">
		        			    			<div class="col-lg-12 width-auto">
		        			    				<table class="table table-striped table-bordered table-hover no-footer" role="grid">
		        			    					<tr>
		                                                <th>帐号ID</th>
		                                                <th>参保人</th>
		                                                <th>参保人电话</th>
		                                                <th>参保人民族</th>
		                                                <th>参保人身份证</th>
		                                                <th>参保人性别</th>
		                                                <th>社保卡号</th>
		                                                <th>公积金账号</th>
		                                                <th>户藉所在地的地址</th>
		                                                <th>收件人</th>
		                                                <th>收件人电话</th>
		                                                <th>邮寄地址</th>
		                                                <th>银行</th>
		                                                <th>银行支行</th>
		                                                <th>银行帐号</th>
		        			    					</tr>
		        			    					<tbody>
		        			    					<c:choose>
		        			    						<c:when test="${empty list }">没有找到相关记录啊</c:when>
		        			    						<c:otherwise>
															<c:forEach items="${list}" var="user">
				        			    					<tr role="row">
				                                                    <td>${user.u_id }</td>
				                                                    <td>${user.user_name }</td>
				                                                    <td>${user.phone }</td>
				                                                    <td>${user.nation }</td>
				                                                    <td>${user.id_card }
				                                                    	<c:if test="${empty user.id_card_img}">
				                                                    		 <input type="button" class="btn btn-warning btn-sm" onclick="updateIdcardImg(${user.id })" value="尝试获取身份证图片" />
				                                                    	</c:if>
				                                                    </td>
				                                                    <td>${user.gender }</td>
				                                                    <td>${user.shebao_card }</td>
				                                                    <td>${user.fund_card }</td>
				                                                    <td>${user.hukou_address }</td>
				                                                    <td>${user.addr_uname }</td>
				                                                    <td>${user.addr_phone }</td>
				                                                    <td>${user.address }</td>
				                                                    <td>${user.bank }</td>
				                                                    <td>${user.bank_branch }</td>
				                                                    <td>${user.bank_code }</td>
				        			    						</tr>
				        			    					</c:forEach>
		        			    						</c:otherwise>
		        			    					</c:choose>
		        			    					</tbody>
		        			    				</table>
		        			    			</div>
		        			    		</div>
		        			    		<hr />
		        			    	</div>
        			    		</div> <!-- .tab-pane -->
		        			    </c:if>
	                            <c:if test="${shebao_user_buyed}">
                                <div class="tab-pane fade in active" id="shebao_user_buyed">
	                                <div class="form-inline dt-bootstrap no-footer">
		        			    		<!-- 表单查询 -->
		        			    		<form action="" method="POST" class="form-check" id="queryForm">
		        			    		<div class="row">
		        			    			<div class="col-lg-12">
		        			    				<input type="text" class="form-control" name="id_card" placeholder="身份证号" value="${id_card }"/>
		        			    			    <button type="submit" class="btn btn-primary">查 询</button>
		        			    			    <button type="button" id="resetBtn" class="btn btn-primary">重置</button>
		        			    			</div>
		        			    		</div>
		        			    		</form>
		        			    		<!-- 分页 -->
		        			    		<div class="row">
		        			    			<div class="col-lg-2">
		        			    			</div>
		        			    			<div class="col-lg-10">
		        			    				<jsp:include page="/WEB-INF/jsp/common/page.jsp">
		        			    					<jsp:param name="formId" value="queryForm"/>
		        			    				</jsp:include>
		        			    			</div>
		        			    		</div>
		        			    		<!-- 表格列表 -->
		        			    		<div class="row">
		        			    			<div class="col-lg-12">
		        			    				<table id="dataContent" class="table table-striped table-bordered table-hover no-footer" role="grid">
		        			    					<thead>
		        			    						<tr>
		                                                    <th>城市 档位</th>
		                                                    <th>姓名</th>
		                                                    <th>户籍</th>
		                                                    <th>公积金</th>
		                                                    <th>操作</th>
		                                                </tr>
		        			    					</thead>
		        			    					<tbody>
		        			    					<c:forEach items="${pageModel.recordList }" var="l">
			        			    					<tr role="row">
		                                                    <td>
		                                                    	${l.city_name }
		                                                    	${l.cid_name }
		                                                    </td>
		                                                    <td>${l.user_name }</td>
		                                                    <td>
		                                                    	<c:if test="${l.hukou == 1}">本市城镇</c:if> 
		                                                    	<c:if test="${l.hukou == 2}">本市农村</c:if>
		                                                    	<c:if test="${l.hukou == 3}">外地城镇</c:if>
		                                                    	<c:if test="${l.hukou == 4}">外地农村</c:if>
		                                                    </td>
		                                                    <td>${l.fund_price }</td>
		                                                    <td>
		                                                    	<a href="javascript:showEditBox(${l.id}, ${l.cid},${l.fund_price });" id="aedit${l.id}">修改</a>
		                                                    </td>
		        			    					</c:forEach>
		
		        			    					</tbody>
		        			    				</table>
		        			    				
		        			    			</div>
		        			    		</div>
		        			    		<!-- 分页 -->
		        			    		<div class="row">
		        			    			<div class="col-lg-2">
		        			    			</div>
		        			    			<div class="col-lg-10">
		        			    				<jsp:include page="/WEB-INF/jsp/common/page.jsp">
		        			    					<jsp:param name="formId" value="queryForm"/>
		        			    				</jsp:include>
		        			    			</div>
		        			    		</div>
		        			    	</div>
		        			    	<div id="editBox" style="display:none;width:180px">
										<form action="" id="edit_form">
											<input type="hidden" class="form-control" id="id" name="id"/>
											档位标识：<input type="text" class="form-control" style="width:120px" id="cid" name="cid"/>
											公积金额：<input type="text" class="form-control" style="width:120px" id="fund_price" name="fund_price"/>
											<button type="button" class="btn btn-primary btn-sm" onclick="javascript:saveEdit()">保存修改</button>
										</form>
									</div>
                                </div>
								</c:if>
								
	                            <c:if test="${black_user}">
                                <div class="tab-pane fade in active" id="black_user">
	                                <div class="form-inline dt-bootstrap no-footer">
		        			    		<!-- 表单查询 -->
		        			    		<form action="" method="POST" class="form-check" id="queryForm">
		        			    		<input type="hidden" name="pageNo" id="black_pageNo" value="${pageModel.pageNo }">
		        			    		<input type="hidden" name="pageSize" id="black_pageSize" value="${pageModel.pageSize }">
		        			    		<div class="row">
		        			    			<div class="col-lg-10">
		        			    				<input type="text" class="form-control" name="id_card" placeholder="身份证  或 手机号" value="${id_card }"/>
		        			    			    <button type="submit" class="btn btn-primary">查 询</button>
		        			    			    <button type="button" id="resetBtn" class="btn btn-primary">重置</button>
		        			    			</div>
		        			    		</div>
		        			    		</form>
		        			    		<!-- 分页 -->
		        			    		<div class="row">
		        			    			<div class="col-lg-2">
		        			    				<button type="button" id="addBtn" onclick="toAddBlack()" class="btn btn-warning">添加黑名单</button>
		        			    			</div>
		        			    			<div class="col-lg-10">
		        			    				<jsp:include page="/WEB-INF/jsp/common/page.jsp">
		        			    					<jsp:param name="formId" value="queryForm"/>
		        			    				</jsp:include>
		        			    			</div>
		        			    		</div>
		        			    		<!-- 表格列表 -->
		        			    		<div class="row">
		        			    			<div class="col-lg-12">
		        			    				<table id="dataContent" class="table table-striped table-bordered table-hover no-footer" role="grid">
		        			    					<thead>
		        			    						<tr>
		                                                    <th>姓名</th>
		                                                    <th>手机号</th>
		                                                    <th>身份证</th>
		                                                    <th>原因</th>
		                                                    <th>操作人</th>
		                                                    <th>加入时间</th>
		                                                    <th>操作</th>
		                                                </tr>
		        			    					</thead>
		        			    					<tbody>
		        			    					<c:forEach items="${pageModel.recordList }" var="l">
			        			    					<tr role="row">
		                                                    <td>${l.uname }</td>
		                                                    <td>${l.phone }</td>
		                                                    <td>${l.idcard }</td>
		                                                    <td>${l.reason }</td>
		                                                    <td>${l.opt_user }</td>
		                                                    <td>${l.gen_time }</td>
		                                                    <td><button type="button" class="btn btn-warning btn-sm" onclick="javascript:delBlack(${l.id })">删除</button></td>
		        			    					</c:forEach>
		
		        			    					</tbody>
		        			    				</table>
		        			    				
		        			    			</div>
		        			    		</div>
		        			    		<!-- 分页 -->
		        			    		<div class="row">
		        			    			<div class="col-lg-2">
		        			    			</div>
		        			    			<div class="col-lg-10">
		        			    				<jsp:include page="/WEB-INF/jsp/common/page.jsp">
		        			    					<jsp:param name="formId" value="queryForm"/>
		        			    				</jsp:include>
		        			    			</div>
		        			    		</div>
		        			    	</div>
		        			    	<div id="addBlackBox" style="display:none;width:380px">
										<form action="" id="add_form">
											<label>姓名：</label>
											<input type="text" class="form-control" style="width:380px" id="uname" name="uname"/>
											<label>身份证号：</label>
											<input type="text" class="form-control" style="width:380px" id="uidcard" name="uidcard"/>
											<label>手机号：</label>
											<input type="text" class="form-control" style="width:380px" id="uphone" name="uphone"/>
											<label>归入黑名单的原因(64字)：</label>
											<input type="text" class="form-control" style="width:380px" id="reason" name="reason"/>
											<br>
											<button type="button" class="btn btn-primary btn-sm" onclick="javascript:saveBlack()">加入黑名单</button>
										</form>
									</div>
                                </div>
								</c:if>
        			    	</div> <!-- .tab-content -->
            			</div>
            		</div>
            	</div>
            </div>
        </div>
	</div>
</body>
<script type="text/javascript">
	function tabSwitch(index) {
		if (index == 0) {
			document.location.href="${user_shebao_manage_uri}";
		} else if (index == 1) {
			document.location.href="${buyed_manager_uri}";
		} else {
			document.location.href="${black_list_uri}";
		}
	}
	
function exportExcel() {
	var form = $("#queryForm");
	form.attr("action", "${user_shebao_export_uri}");
	form.submit();
	form.attr("action", "${user_shebao_manage_uri}");
}

function showEditBox(id, cid, fund_price) {
	   $("#id").val(id);
	   $("#cid").val(cid);
	   $("#fund_price").val(fund_price);

    var content=document.getElementById("editBox");
    dialog({
  	  title: '修改',
  	  content: content,
  	  follow: document.getElementById("aedit"+id),
  	  quickClose:true}).show();
 }
 

 function saveEdit() {
	   var data = $("#edit_form").serialize();
	   jQuery.ajax({
		   url: "${buyed_edit_uri}",
		   data: data,
		   type:'post', 
		   async : true, //默认为true 异步
		   error: function(jqXHR, textStatus, errorThrown) {
			   
		   },
		   success:function(result){
			   smokeAlert(result.code, result.msg);
			   if (result.code == 200) {
				   window.location.reload();
			   }
		   }
	   });
 }


 function toAddBlack() {

     var content=document.getElementById("addBlackBox");
     dialog({
   	  title: '新增参保人黑名单',
   	  content: content,
   	  follow: document.getElementById("addBtn"),
   	  quickClose:true}).show();
  }

 function saveBlack() {
	   var data = $("#add_form").serialize();
	   jQuery.ajax({
		   url: "${black_add_uri}",
		   data: data,
		   type:'post', 
		   async : true, //默认为true 异步
		   error: function(jqXHR, textStatus, errorThrown) {
			   
		   },
		   success:function(result){
			   smokeAlert(result.code, result.msg);
			   if (result.code == 200) {
				   window.location.reload();
			   }
		   }
	   });
}
 function delBlack(idV) {
	   jQuery.ajax({
		   url: "${black_del_uri}",
		   data: {id: idV},
		   type:'post', 
		   async : true, //默认为true 异步
		   error: function(jqXHR, textStatus, errorThrown) {
			   
		   },
		   success:function(result){
			   smokeAlert(result.code, result.msg);
			   if (result.code == 200) {
				   window.location.reload();
			   }
		   }
	   });
}

function updateIdcardImg(id) {
	var data = {sbu_id: id}
	jQuery.ajax({
		   url: "${update_cardimg_uri}",
		   data: data,
		   type:'post', 
		   async : true, //默认为true 异步
		   error: function(jqXHR, textStatus, errorThrown) {
			   
		   },
		   success:function(result){
			   if (result.code == 200) {
				   smokeAlert(result.code, "已配置通过51公积金的服务尝试获取身份证图片，每逢10分钟获取。 ");
			   } else {
				   smokeAlert(result.code, result.msg);
			   }
		   }
	   });
}
</script>
</html>